home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 22 / Cream of the Crop 22.iso / bbs / low_1123.zip / MSGADJ10.ZIP / MSGADJ.CMD < prev   
OS/2 REXX Batch file  |  1996-10-29  |  5KB  |  163 lines

  1. /* MSGADJ.CMD -  version 1.0 October 29, 1996 */
  2. /* Adjust MaxMsg in SysMsg.dat to reflect average weekly
  3.     msg stats from Running.txt file.
  4. This uses my MSGCNT.CMD and RUNNING.CMD programs' output
  5. so you'll probably need them. But it'll show you how to
  6. adjust SysMsg.Dat if that's all you're interested in.
  7. Send netmail to Elliott Goodman 1:2004/102 if you have questions
  8. or problems. */
  9.  
  10. /* load RexxUtil functions */                              
  11. if RxFuncQuery('SysLoadFuncs') then                        
  12. do                                                         
  13.   call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  14.   call SysLoadFuncs                                        
  15. end                                                        
  16.  
  17.  
  18. /* constants */
  19. DataFile = "SYSMSG.DAT"   /* no drive/path since REN barfs with that */
  20. SaveFile = "SYSMSGDT.BAK"
  21. StatFile = "D:\LORA\LANG\RUNNING.TXT"
  22. OutFile = "TEST.DAT"
  23. ViewFile = "D:\LORA\LANG\1MSGADJ.TXT"
  24. Target = "D:\LORA"
  25. semname = "D:\MSGP.SEM" 
  26. MaxMsgCount = 1575        /* for a max of 1600 */
  27. MinMsgCount = 175        /* for a min of 200   */
  28.  
  29. 'c:\sio\su 2 dcd'
  30. if rc = 1 then do
  31.    say "Carrier is detected - Someone online! Aborting..."
  32.    call SysSleep 5
  33.    exit
  34.    end
  35.  
  36. if SemaphorePresent(semname) then do
  37.    say "Messages being packed! Aborting...."
  38.    call SysSleep 5
  39.    exit
  40.    end
  41.  
  42. if \SemaphorePresent(StatFile) then do
  43.    say StatFile "not found!"
  44.    exit
  45.    end
  46.  
  47. call Directory(Target)
  48. call SysFileDelete(SaveFile)    /* delete old save file */
  49. call SysFileDelete(ViewFile)
  50.  
  51. /* open sysmsg.dat file, calculate number of records */
  52. size = stream(DataFile, 'c', 'query size')
  53. if size = '' then do
  54.    say "File not found!"
  55.    return 0
  56.    end
  57. records = size % 512
  58. say "Number of records:" records
  59.  
  60. call lineout DataFile
  61.  
  62. /* retrieve all records from sysmsg.dat */
  63. do count = 1 to records
  64.   templine.count = charin(DataFile,, 512)
  65.   end
  66.  
  67. call lineout DataFile
  68.  
  69. call SysSleep 3
  70. /* save sysmsg.dat file to another name */
  71. '@copy ' DataFile SaveFile
  72.  
  73. /* get echo number, echotag and max msg number for each echo */
  74. /* convert max number to usable form */
  75. do count = 1 to records
  76.    workline = templine.count
  77.    echonum1 = substr(workline, 71, 1)
  78.    echonum2 = substr(workline, 72, 1)
  79.    edata.count.echonum = (256 * x2d(c2x(echonum2))) + x2d(c2x(echonum1))
  80.    echotag = substr(workline, 172, 32)
  81.    echotag.count = strip(echotag, T, "0"x)
  82.    max1 = substr(workline, 218, 1)
  83.    max2 = substr(workline, 219, 1)
  84.    edata.count.maxnum = (256 * x2d(c2x(max2))) + x2d(c2x(max1))
  85.    end
  86.  
  87. /* read in data from Running.txt file */
  88. index = 1
  89. do while lines(StatFile) > 0
  90.    workline = linein(StatFile)
  91.    parse upper var workline StatTag Daily stuff
  92.    if StatTag = "RUNNING" then iterate
  93.    if StatTag = "CURRENT" then iterate
  94.    if StatTag = "DAYS" then iterate
  95.    if StatTag = "TOTAL" then iterate
  96.    StatTag.index = StatTag
  97.    Snum.index = Daily   
  98.    index = index + 1
  99.    end
  100. call lineout StatFile
  101. StatCount = index -1
  102.  
  103. say "StatCount:" StatCount
  104. say ' '
  105.  
  106. /* calculate max msg number from Running.txt,
  107. find corresponding number from Sysmsg.dat file
  108. and adjust number to lie within max and min
  109. while setting optimum number */
  110. do count = 3 to records
  111.    if edata.count.echonum = 19 then iterate
  112.    flag = 0
  113.    do index = 1 to StatCount
  114.       if echotag.count \= StatTag.index then iterate
  115.       flag = 1
  116.       tfix = trunc(Snum.index * 7)
  117.       tfix = min(MaxMsgCount, tfix, edata.count.maxnum)
  118.       tfix = max(tfix, MinMsgCount)
  119.       tfix = ((tfix % 25) * 25) + 25
  120.       if left(echotag.count,3) = "OS2" then
  121.          tfix = max(tfix, 400)
  122.       m_txt = echotag.count tfix
  123.       m_txt = space(m_txt, (30 - length(m_txt)), ' ')
  124.       m_txt = translate(m_txt, '.', ' ')
  125.       call lineout ViewFile, m_txt
  126.  
  127. /* convert to absolute numbers and put in reverse order
  128. to match format of Sysmsg.dat file */
  129.       test = d2x(tfix)
  130.       len = length(test)
  131.       if len > 2 then do
  132.          last = x2c(right(test, 2))
  133.          first = x2c(left(test, (len -2)))
  134.          end
  135.       else do
  136.          first = "0"x
  137.          last = x2c(test)
  138.          end
  139.       tover = last || first
  140. /* write new number to memory object of Sysmsg.dat */
  141.       templine.count = overlay(tover, templine.count, 218)
  142.       leave
  143.       end
  144.    if flag = 0 then iterate
  145.    end
  146.  
  147. call lineout ViewFile
  148.  
  149. /* actually write new Sysmsg.dat file */
  150. do count = 1 to records
  151.    dummy = charout(OutFile, templine.count)
  152.    end
  153.  
  154. call charout(OutFile)
  155. call SysFileDelete(DataFile)
  156. call SysSleep 3
  157. '@ren' OutFile DataFile
  158. exit
  159.  
  160. /* test for presence of semaphore file */            
  161. SemaphorePresent: Procedure                          
  162.   return stream(arg(1), 'c', 'query exists') <> ''   
  163.